/**
 * Created by Think pad on 2016/4/24.
 */
import java.util.Date;
import java.util.logging.*;

public class FormatterDemo {
    public static void main(String[] args) {
        Logger logger = Logger.getLogger(FormatterDemo.class.getName());
        logger.setLevel(Level.FINE);
        ConsoleHandler handler = new ConsoleHandler();
        handler.setLevel(Level.CONFIG);
        handler.setFormatter(new Formatter() {
            @Override
            public String format(LogRecord record) {
                return "日志来自"       + record.getSourceClassName()
                                          + record.getSourceMethodName() + "\n"
                        + "\t 层级\t：" + record.getLevel() + "\n"
                        + "\t 信息\t：" + record.getMessage() + "\n"
                        + "\t 时间\t：" + new Date(record.getMillis())
                        + "\n";
            }
        });
        logger.addHandler(handler);
        logger.config("自定义 Fomatter 信息");
    }
}
